﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Data.SqlClient;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace FinalText
{
    public partial class Register : Form
    {
        public Register()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {


            var uid = textBox1.Text;
            var pwd = textBox2.Text;
            var rePwd = textBox3.Text;

            var hasUid = !string.IsNullOrEmpty(uid);
            var hasPwd = !string.IsNullOrEmpty(pwd);
            var eqPwd = pwd == rePwd;

            if (uid == "" || pwd == "")
            {
                MessageBox.Show("不能为空");
            }
            else
            {
                try
                {

                    if (hasUid && hasPwd && eqPwd)
                    {
                        MessageBox.Show("注册成功！");

                        string conn = string.Format("insert into Users(Username,Password) values ('{0}',{1})", uid, pwd);

                        DbHelp.GetDataTable(conn);

                        this.Close();
                    }
                    else
                    {
                        MessageBox.Show("注册失败！");
                    }
                }
                catch { }
            }


            
        }

        private void button2_Click(object sender, EventArgs e)
        {
            this.Close();
        }
    }
}
